package shujia.day19;

import java.util.HashSet;
import java.util.Random;
import java.util.Set;
import java.util.function.Supplier;

/*
    供给型接口
    @FunctionalInterface
    public interface Supplier<T> {
        T get();
    }

 */
class Test5{
    public static Set<Integer> fun1(Supplier<Integer> supplier){
        HashSet<Integer> set = new HashSet<>();
        while (set.size()<10){
            Integer number = supplier.get();
            set.add(number);
        }
        return set;
    }
}

public class LambdaDemo5 {
    public static void main(String[] args) {
        Set<Integer> set = Test5.fun1(() -> new Random().nextInt(100) + 1);

        for (Integer num : set) {
            System.out.println(num);
        }
    }
}
